package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第二页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamNinthActivity extends AbstractControlActivity implements
		OnClickListener {

	private String createDate;
	private int[] checkNxgjbIds = { R.id.check_naoxueguanjb_qxxzz,
			R.id.check_naoxueguanjb_ncx, R.id.check_naoxueguanjb_zwmcx,
			R.id.check_naoxueguanjb_dzxncx };

	private int[] checkSzjbIds = { R.id.check_shenzangjb_tnbsb,
			R.id.check_shenzangjb_sgnsj, R.id.check_shenzangjb_jxsy,
			R.id.check_shenzangjb_mxsy };

	private int[] checkXzjbIds = { R.id.check_xinzangjb_xjgs,
			R.id.check_xinzangjb_xjt, R.id.check_xinzangjb_gzdm,
			R.id.check_xinzangjb_cxx, R.id.check_xinzangjb_xqqtt };

	private int[] checkXgjbIds = { R.id.check_xueguanjb_jcdml,
			R.id.check_xueguanjb_dmbsxjb };

	private int[] checkYbjbIds = { R.id.check_yanbujb_swmcx,
			R.id.check_yanbujb_srtsz, R.id.check_yanbujb_bnz };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_ninth);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addCheckBoxView(checkNxgjbIds, "脑血管疾病");
		addEditTextView(R.id.edt_naoxueguanjb_qita, "脑血管疾病-其他");
		addCheckBoxView(checkSzjbIds, "肾脏疾病");
		addEditTextView(R.id.edt_shenzangjb_qita, "肾脏疾病-其他");
		addCheckBoxView(checkXzjbIds, "心脏疾病");
		addEditTextView(R.id.edt_xinzangjb_qita, "心脏疾病-其他");
		addCheckBoxView(checkXgjbIds, "血管疾病");
		addEditTextView(R.id.edt_xueguanjb_qita, "血管疾病-其他");
		addCheckBoxView(checkYbjbIds, "眼部疾病");
		addEditTextView(R.id.edt_yanbujb_qita, "眼部疾病-其他");

		addRadioGroupView(R.id.rad_shenjingxtjb, "神经系统疾病");
		addRadioGroupView(R.id.rad_qitaxtjb, "其他系统疾病");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();

		this.setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamEighthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamTenthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
